/* const arr = ["a", "b", "c"];
console.log(arr[1])

const a = "name";
const obj = {
  id: 1,
  name: "jack"
}
console.log(obj[a]); */

type Person = {
  id: number;
  name: string;
  age: number;
  sex: "男"|"女"
}

type ObjValueType = Person['sex']; // "男"|"女"

const arr: string[] = ["a", "b", "c"];

type ArrValueType = typeof arr[number] // string


type User = {
  name: string
  age: number
}

const users: User[] = [
  {name: "jack", age: 20},
  {name: "tom", age: 30}
]

type ObjType = typeof users[number] // {name: string; age: number;}

const p: [number, string] = [1, "jack"];

type TupleType1 = typeof p[number]; // number | string

const roles1: ["Admin", "User", "Guest"] = ["Admin", "User", "Guest"];

type TupleType2 = typeof roles1[number]; // "Admin" | "User" | "Guest"


// as const

const roles2 = ["角色列表", "用户列表", "用户查询", "权限详情", "管理员列表"] as const;
type Role = typeof roles2[number]; // "角色列表" | "用户列表" | "用户查询" | "权限详情" | "管理员列表"
